import http from '../index'

// 分页获取后台菜单
export const getMenus = ({ ascended = null, current = null, size = null, sortFieldName = null, menuName = null, parentTreeCode = null, status = null }) => {
    return http.get("menus", { ascended, current, size, sortFieldName, menuName, parentTreeCode, status })
}

// 获取后台菜单下拉树列表
export const getMenusTree = () => {
    return http.get("menus/treeSelect")
}

// 获取后台已启用菜单下拉树列表
export const getRightMenusTree = () => {
    return http.get("menus/right-tree")
}

// 根据sid获取后台菜单
export const getMenuDetail = ({ sid }) => {
    return http.get("menus/" + sid)
}

// 新增后台菜单
export const addMenu = ({ menuName, permission, type, component = null, icon = null, isFrame = null, deletable = null, note = null, status = null, parentTreeCode = null, path = null, query = null, viewSort = null, visible = null }) => {
    return http.post("menus", { menuName, permission, type, component, icon, isFrame, deletable, note, status, parentTreeCode, path, query, viewSort, visible })
}

// 修改后台菜单
export const editMenu = ({ sid, menuName, permission, type, component = null, icon = null, isFrame = null, deletable = null, note = null, status = null, path = null, query = null, viewSort = null, visible = null }) => {
    return http.put("menus/" + sid, { menuName, permission, type, component, icon, isFrame, deletable, note, status, path, query, viewSort, visible })
}

// 批量删除后台菜单
export const delMenus = ({ sidList }) => {
    return http.put("menus/delete", { sidList })
}

// 分页获取小程序菜单
export const getMiniMenus = ({ ascended = null, current = null, size = null, sortFieldName = null, menuName = null, parentTreeCode = null, status = null }) => {
    return http.get("miniapp-menus", { ascended, current, size, sortFieldName, menuName, parentTreeCode, status })
}

// 获取小程序菜单下拉树列表
export const getMiniMenusTree = () => {
    return http.get("miniapp-menus/tree")
}

// 获取小程序已启用菜单下拉树列表
export const getRightMiniMenusTree = () => {
    return http.get("miniapp-menus/right-tree")
}

// 根据sid获取小程序菜单
export const getMiniMenuDetail = ({ sid }) => {
    return http.get("miniapp-menus/" + sid)
}

// 新增小程序菜单
export const addMiniMenu = ({ menuName, permission, type, component = null, icon = null, isFrame = null, deletable = null, note = null, status = null, parentTreeCode = null, path = null, query = null, viewSort = null, visible = null }) => {
    return http.post("miniapp-menus", { menuName, permission, type, component, icon, isFrame, deletable, note, status, parentTreeCode, path, query, viewSort, visible })
}

// 修改小程序菜单
export const editMiniMenu = ({ sid, menuName, permission, type, component = null, icon = null, isFrame = null, deletable = null, note = null, status = null, path = null, query = null, viewSort = null, visible = null }) => {
    return http.put("miniapp-menus/" + sid, { menuName, permission, type, component, icon, isFrame, deletable, note, status, path, query, viewSort, visible })
}

// 批量删除小程序菜单
export const delMiniMenus = ({ sidList }) => {
    return http.put("miniapp-menus/delete", { sidList })
}
